/**
 * 只有两项的下拉框
 */
Ext.namespace('Ext.ux');

Ext.ux.TwoItemComboBox = Ext.extend(Ext.form.ComboBox, {
	
	itemType: 'default', //default,boolean,sex
	
	allowBlank: true,
	
	item1Label: '',
	item1Value: '',
	
	item2Label: '',
	item2Value: '',

	displayField: 'label',
	valueField: 'value',
	emptyText: '请选择...',
	editable: false,
	mode: 'local',
	triggerAction: 'all',
	
	// 组件初始化
	initComponent: function(){
		
		if(this.itemType == 'boolean'){
			this.item1Label = '是';
			this.item1Value = '1';
			this.item2Label = '否';
			this.item2Value = '0';
		}else if(this.itemType == 'sex'){
			this.item1Label = '男';
			this.item1Value = 'M';
			this.item2Label = '女';
			this.item2Value = 'F';
		}
		
		var data;
		if(this.allowBlank)
			data = [['请选择...', ''], [this.item1Label, this.item1Value], [this.item2Label, this.item2Value]];
		else
			data = [[this.item1Label, this.item1Value], [this.item2Label, this.item2Value]]	
		
		this.store = new Ext.data.ArrayStore({fields:['label', 'value'], data:data});
		
		Ext.ux.TwoItemComboBox.superclass.initComponent.call(this);
	}
});

Ext.reg('twoItemCombo', Ext.ux.TwoItemComboBox);